import 'package:simulator/typedef/simu_option.dart';
import 'package:simulator/utils/module.dart';

final Option bdrvRuntimeOpts = Option(name: 'bdrv_common', desc: const [
  OptDescription(
      name: 'node-name',
      type: OptType.string,
      help: 'Node name of the block device node'),
  OptDescription(
      name: 'driver',
      type: OptType.string,
      help: 'Block driver to use for the node'),
  OptDescription(
      name: 'cache.direct',
      type: OptType.bool,
      help: 'Bypass software writeback cache on the host'),
  OptDescription(
      name: 'cache.no-flush',
      type: OptType.bool,
      help: 'Ignore flush requests'),
  OptDescription(
      name: 'read-only',
      type: OptType.bool,
      help: 'Node is opened in read-only mode'),
  OptDescription(
      name: 'auto-read-only',
      type: OptType.bool,
      help: 'Node can become read-only if opening read-write fails'),
  OptDescription(
      name: 'detect-zeroes',
      type: OptType.string,
      help: 'try to optimize zero writes (off, on, unmap)'),
  OptDescription(
      name: 'discard',
      type: OptType.string,
      help: 'discard operation (ignore/off, unmap/on)'),
  OptDescription(
      name: 'force-share',
      type: OptType.bool,
      help: 'always accept other writers (default: off)'),
]);

class Block {
  static final Block _instance = Block._internal();
  Block._internal();
  static Block getInstance() => _instance;
  /* If non-zero, use only whitelisted block drivers */
  static int useBdrvWhitelist = 0;
  void init() {
    useBdrvWhitelist = 1;
    moduleCallInit(ModuleInitType.block);
  }
}
